#Developed by Dylan Pavelko
#Created: May 9, 2012
#Last Updated: May 10, 2012

from django.db import models
from copy import deepcopy

class Property(models.Model):
	name = models.CharField(max_length=50)
	value = models.CharField(max_length=50)
	defaultOffValue = models.CharField(max_length=50)
	
	def __unicode__(self):
		return self.name
		
	def save(self):
		super(Property, self).save()
		
	def jsonValue(self):
		return "{\"name\":\"" + self.name +"\", \"value\":\""+self.value +"\"}"
	
class Setting(models.Model):
	name = models.CharField(max_length=50)
	properties = models.ManyToManyField(
		Property, 
		verbose_name="Properties")
		
	def __unicode__(self):
		return self.name
	    
class FixtureType(models.Model):
	name = models.CharField(max_length=50)
	DEVICE_TYPE_CHOICES = (
    	('ACN', 'ACN'),
    	('DMX', 'DMX'),
    )
	deviceType = models.CharField(max_length=3, choices=DEVICE_TYPE_CHOICES)
	settings = models.ForeignKey(
		Setting, 
		verbose_name="Device Settings")
		
	def __unicode__(self):
		return self.name
		
class Fixture(models.Model):
	name = models.CharField(max_length=50)
	fixtureType = models.ForeignKey(
		FixtureType, 
		verbose_name="Fixture Type")
	fixtureSettings = models.ForeignKey(
		Setting, 
		verbose_name="Fixture Settings")
		
	def __unicode__(self):
		return self.name